<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改密码 - 析码无界</title>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
    <script src="http://cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            padding-top: 20px;
        }
        .panel {
            border: none;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            border-radius: 8px;
        }
        .panel-heading {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 8px 8px 0 0;
        }
        .btn-primary {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border: none;
        }
        .form-control:focus {
            border-color: #667eea;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title"><i class="fa fa-lock"></i> 修改密码</h3>
            </div>
            <div class="panel-body">
                <div th:if="${message}" class="alert alert-success" th:text="${message}"></div>
                <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>
                
                <form th:action="@{/teacher/changePassword}" method="post" class="form-horizontal" id="passwordForm">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">旧密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" name="oldPassword" 
                                   placeholder="请输入旧密码" required>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-2 control-label">新密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" name="newPassword" 
                                   placeholder="请输入新密码" required>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <label class="col-sm-2 control-label">确认新密码</label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control" id="confirmPassword" 
                                   placeholder="请再次输入新密码" required>
                        </div>
                    </div>
                    
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="submit" class="btn btn-primary">
                                <i class="fa fa-key"></i> 修改密码
                            </button>
                            <a th:href="@{/teacher}" class="btn btn-default">
                                <i class="fa fa-arrow-left"></i> 返回主页
                            </a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <script>
        document.getElementById('passwordForm').addEventListener('submit', function(e) {
            const newPassword = document.querySelector('input[name="newPassword"]').value;
            const confirmPassword = document.getElementById('confirmPassword').value;
            if (newPassword !== confirmPassword) {
                e.preventDefault();
                alert('两次输入的密码不一致！');
                return false;
            }
        });
    </script>
</body>
</html>

